<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.2.1/axios.js"></script>
</head>

<body>
    <button>发送请求</button>
    <script>
        // 获取按钮
        let btns = document.querySelectorAll('button');

        // 监听2个axios执行结果及定义回调
        btns[0].onclick =async function(){
            //定义2个axios调用 
            // axios返回的就是promise对象
            let p1 = axios({
                url:'http://api.zhibao.com:3000/movies/1'
            });
            let p2 = axios('http://api.zhibao.com:3000/movies/2');

            let [{data:id1Data},{data:id2Data}] = await axios.all([p1,p2]);

            console.log(id1Data);
            console.log(id2Data);
        }
    </script>
</body>

</html>